<template>
  <div>
    <br/>
    <el-form :model="formData" :rules="formrules" label-width="200px">
      <el-form-item label='运费满减不足所需运费' prop="shopping_express_freight_value">
        <el-input v-model="formData.shopping_express_freight_value"></el-input>
      </el-form-item>
      <el-form-item label="运费满减所需最低消费" prop="shopping_mall_min">
        <el-input v-model="formData.shopping_mall_min"></el-input>
      </el-form-item>
      <el-form-item style="display: flex;justify-content: flex-end;margin-top: 10px">
        <el-button @click="add">确定</el-button>
        <el-button @click="reset">重值</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
  
<script>
import axios from 'axios'
export default {
  name: 'freightConfig',
  componentTitle: '运费配置',
  data () {
    return {
      formData:{
        shopping_express_freight_value:'12',
        shopping_mall_min:'12'
      },
      formrules:{
        shopping_express_freight_value:[
          {required: true, message: '不能为空'}
        ],
        shopping_mall_min:[
          {required: true, message: '不能为空'}
        ]
      }
    }
  },
  methods:{
    reset(){
      this.formData.shopping_express_freight_value='12',
      this.formData.shopping_mall_min='12'
    },
    add(){
      axios({
        url:'http://192.168.200.251:8888/admin/config/express',
        method:'get',
        data:{
          shopping_express_freight_value:this.formData.shopping_express_freight_value,
          shopping_mall_min:this.formData.shopping_mall_min
        },
        headers:{
          'Shopping-Admin-Token': sessionStorage.getItem('Shopping-Admin-Token')
        }
      }).then(res=>{
        if(res.data.errno === 0){
          this.$notify.success({title:'修改成功'})
        }else{
          this.$notify.error({title:'修改失败'})
        }
      })
    }
  }
}
</script>

